package main

import (
	"fmt"
)

func main() {

	sliceInt := []int{1, 2, 3, 4, 5}
	ints := sliceInt[0:2:4]
	fmt.Println(ints)
	//var number = 10
	//fmt.Printf("%T：%d", number, number)
	//fmt.Println()
	//var float1 float32 = 1.1
	//fmt.Printf("%T：%f", float1, float1)
	//fmt.Println()
	//var boolean bool
	//fmt.Printf("%T：%t", boolean, boolean)
	//fmt.Println()
	//var str = "星星有泪"
	//fmt.Printf("%T：%s", str, str)
	//fmt.Println()
	//
	//var str1 = "qwerasdfzxcv"
	//for k, r := range str1 {
	//	fmt.Printf("%d：%c ", k, r)
	//}
	//
	//fmt.Println(number)
	//var numAdd *int = &number
	//fmt.Printf("%T：%d：%b", numAdd, numAdd, numAdd)
	//
	//gotoDemo()
	//
	//breakDemo1()
	//
	//continueDemo()
	//
	//multiplicationTable()

	//deferDemo()
}

func deferDemo() {
	defer fmt.Println("A")
	fmt.Println("B")
	// B  A
}

func multiplicationTable() {
	for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%d * %d = %d；", j, i, i*j)
		}
		fmt.Println()
	}
}

func continueDemo() {
CONTINUEDEMO:
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if j == 1 {
				continue CONTINUEDEMO
			}
			fmt.Printf("i:%d,j:%d", i, j)
			fmt.Println()
		}
	}
}

func breakDemo1() {
BREAKDEMO1:
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if j == 2 {
				break BREAKDEMO1
			}
			fmt.Println(j)
		}
	}
	fmt.Println("end")
}

func gotoDemo() {
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if j == 2 {
				goto breakTag
			}
			fmt.Println(j)
		}
	}

breakTag:
	fmt.Println("end")
}
